<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>Project name</title>
		<!-- Meta -->
		<meta name="author" content="Marcel" />
		<meta name="description" content="" />
		<meta name="keywords" content="" />
		
		<!-- CSS -->
		<style type="text/css">
		body { margin:0; padding:0; font-family:arial; font-size:10px }
		</style>
		
		<!-- JS -->
		<script type="text/javascript" src="web/js/swfobject.js"></script>
		<script type="text/javascript" src="web/js/swfaddress.js"></script>
		<script type="text/javascript">
			
			var flashvars = {};
			flashvars.c = "fr";
			flashvars.l = "fr";
			flashvars.htmlembed = "true";
			flashvars.site_xml = "web/xml/config/site.xml";
			flashvars.enable_debug = "true";
			if (window.location.hash.length > 0) flashvars.state = window.location.hash.substring(1);
			
			var params = {};
			params.allowscriptaccess  = "always";
			params.allowfullscreen  = "true";
			params.scale = "noscale";
			params.menu = "false";
			params.quality = "high";
			params.bgcolor = "#DDDDDD";
			params.wmode = "opaque";
			
			var attributes = {};
			attributes.id = "mainswf";
			attributes.name = "mainswf";
	
			swfobject.embedSWF("web/swf/main.swf", "flashcontent", "516", "500", "9.0.115", "web/swf/expressInstall.swf", flashvars, params, attributes);
			
			//]]>
        </script>
		
	</head>
	
	<body>
		<div id="fb-root"></div>
		<script src="https://connect.facebook.net/fr_FR/all.js"></script>
		<script>
			
			////////////////////////////////
			var app_id = '146168738734269';
			var app_perms = 'email,user_birthday';
			////////////////////////////////
			
			FB.init({
				appId  : app_id,
				status : true, // check login status
				cookie : true, // enable cookies to allow the server to access the session
				xfbml  : true // parse XFBML
			});
			
			function sendResponseToFlash(type, value)
			{
				var f = document.getElementById("mainswf")
				if (f) f.sendResponse(type, value);
				else console.log("Flash object not found");
			}
			
			function setFBCanvasHeight(height)
			{
				FB.Canvas.setSize({height: height});
			}
			
			function authorizeApp()
			{
				var sess = FB.getSession();
				if (sess) sendResponseToFlash("token", sess.access_token);
				else
				{
					FB.ui({method:'permissions.request', perms:app_perms},
						function(response)
						{
							if (response && response.session) sendResponseToFlash("token", response.session.access_token);
							else console.log("App not authorized");
						}
					);
				}
			}
			
			function publish(fbTitle, fbCaption, fbDesc, fbLink, fbPict) {
				FB.ui(
					{
						method: 'feed',
						name: unescape(fbTitle),
						link: unescape(fbLink),
						picture: unescape(fbPict),
						caption: unescape(fbCaption),
						description: unescape(fbDesc)
						/*
						to publish video or swf, add :
						source: 'http://.../myswf.swf',
						type: 'video'
						*/
					},
					function(response)
					{
						if (response && response.post_id) sendResponseToFlash("publish", response.post_id);
						else console.log("Error occured while sharing");
					}
				);
			}
			
			function sendNotification(fbTitle, fbMessage, fbMaxRecipients)
			{
				if (isNaN(fbMaxRecipients)) fbMaxRecipients = 50;
				FB.ui(
					{
						method: 'apprequests',
						title: unescape(fbTitle),
						message: unescape(fbMessage),
						max_recipients: fbMaxRecipients
					},
					function(response)
					{
						if (response) sendResponseToFlash("send", response);
						else console.log("Error occured while sending");
					}
				);
			}
			
		</script>
		<div id="content">
			<div id="flashcontent"></div>
		</div>
		<!--
		<input type="button" value="test auth" onclick="authorizeApp();"/>
		<br/>
		<input type="button" value="test publish" onclick="publish('titre', 'caption', 'desc', 'http://www.google.fr', 'http://media2.wearehunted.com/media/images/logo/wah_logo_genre.png');"/>
		<br/>
		<input type="button" value="test send" onclick="sendNotification('titre', 'message', 5);"/>
		 -->
	</body>
	
</html>